Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Latest commit

 

History

History
20 lines (16 loc) · 666 Bytes

2.3.42 - enable_delay_receive.md

File metadata and controls

20 lines (16 loc) · 666 Bytes

enable_delay_receive

设置此选项为true后,accept客户端连接后将不会自动加入EventLoop,仅触发onConnect回调。worker进程可以调用$serv->confirm($fd)对连接进行确认,此时才会将fd加入EventLoop开始进行数据收发,也可以调用$serv->close($fd)关闭此连接。

实例:

//开启enable_delay_receive选项
$serv->set(array(
    'enable_delay_receive' => true,
));

$serv->on("Connect", function ($serv, $fd, $reactorId) {
	$serv->after(2000, function() use ($serv, $fd) {
		//确认连接,开始接收数据
		$serv->confirm($fd);
	});
});

enable_delay_receive在1.8.8或更高版本可用